home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / H / access / genam.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-07  |  7.3 KB  |  364 lines

  1. /* ----------------------------------------------------------------
  2.  *   FILE
  3.  *    genam.h
  4.  *
  5.  *   DESCRIPTION
  6.  *    POSTGRES general access method definitions.
  7.  *
  8.  *   IDENTIFICATION
  9.  *    $Header: /private/postgres/src/lib/H/access/RCS/genam.h,v 1.8 1992/02/12 13:26:02 olson Exp $
  10.  * ----------------------------------------------------------------
  11.  */
  12. #ifndef    GenAMIncluded
  13. #define GenAMIncluded    1
  14.  
  15. #include "tmp/postgres.h"
  16.  
  17. #include "access/attnum.h"
  18. #include "access/attval.h"    /* XXX for AMgetattr */
  19. #include "access/itup.h"
  20. #include "access/relscan.h"
  21. #include "access/skey.h"
  22. #include "access/sdir.h"
  23.  
  24. /* ----------------
  25.  *    generalized index_ interface routines
  26.  * ----------------
  27.  */
  28. extern
  29. Relation
  30. index_open ARGS((
  31.     ObjectId    relation
  32. ));
  33.  
  34. extern
  35. Relation
  36. index_openr ARGS((
  37.     Name        relationName
  38. ));
  39.  
  40. extern
  41. void
  42. index_close ARGS((
  43.     Relation    relation
  44. ));
  45.  
  46. extern
  47. GeneralInsertIndexResult
  48. index_insert ARGS((
  49.     Relation    relation,
  50.     IndexTuple    indexTuple,
  51.     double        *offsetOutP    /* XXX unused */
  52. ));
  53.  
  54. extern
  55. void
  56. index_delete ARGS((
  57.     Relation    relation,
  58.     ItemPointer    indexItem
  59. ));
  60.  
  61. extern
  62. IndexScanDesc
  63. index_beginscan ARGS((
  64.     Relation    relation,
  65.     Boolean        scanFromEnd,
  66.     uint16        numberOfKeys,
  67.     ScanKey        key
  68. ));
  69.  
  70. extern
  71. void
  72. index_rescan ARGS((
  73.     IndexScanDesc    scan,
  74.     bool        scanFromEnd,
  75.     ScanKey        key
  76. ));
  77.  
  78. extern
  79. void
  80. index_endscan ARGS((
  81.     IndexScanDesc    scan
  82. ));
  83.  
  84. extern
  85. void
  86. index_markpos ARGS((
  87.     IndexScanDesc    scan
  88. ));
  89.  
  90. extern
  91. void
  92. index_restrpos ARGS((
  93.     IndexScanDesc    scan
  94. ));
  95.  
  96. extern
  97. RetrieveIndexResult
  98. index_getnext ARGS((
  99.     IndexScanDesc    scan,
  100.     ScanDirection    direction
  101. ));
  102.  
  103. extern
  104. RegProcedure
  105. index_getrprocid ARGS((
  106.     Relation    irel,
  107.     AttributeNumber    attnum,
  108.     uint16        procnum
  109. ));
  110.  
  111. extern
  112. IndexTuple
  113. index_formtuple ARGS((
  114.     AttributeNumber    numberOfAttributes,
  115.     TupleDescriptor    tupleDescriptor,
  116.     Datum        value[],
  117.     char        nulls[]
  118. ));              
  119.               
  120. /* ----------------
  121.  *    Predefined routines.  Comment from genam.c:
  122.  *
  123.  * All indexed access methods use an identical scan structure.
  124.  * We don't know how the various AMs do locking, however, so we don't
  125.  * do anything about that here.
  126.  *
  127.  * The intent is that an AM implementor will define a front-end routine
  128.  * that calls this one, to fill in the scan, and then does whatever kind
  129.  * of locking he wants.
  130.  * ----------------
  131.  */
  132. /*
  133.  * RelationGetIndexScan --
  134.  *    General access method initialize index scan routine.
  135.  */
  136. extern
  137. IndexScanDesc
  138. RelationGetIndexScan ARGS((
  139.     Relation    relation,
  140.     Boolean        scanFromEnd,
  141.     uint16        numberOfKeys,
  142.     ScanKey        key
  143. ));
  144. /*
  145.  * IndexScanRestart --
  146.  *    General access method restart index scan routine.
  147.  */
  148. extern
  149. void
  150. IndexScanRestart ARGS((
  151.     IndexScanDesc    scan,
  152.     bool        scanFromEnd,
  153.     ScanKey        key
  154. ));
  155.  
  156. /*
  157.  * IndexScanEnd --
  158.  *    General access method end index scan routine.
  159.  */
  160. extern
  161. void
  162. IndexScanEnd ARGS((
  163.     IndexScanDesc    scan
  164. ));
  165.  
  166. /*
  167.  * IndexScanMarkPosition --
  168.  *    General access method mark index scan position routine.
  169.  */
  170. extern
  171. void
  172. IndexScanMarkPosition ARGS((
  173.     IndexScanDesc    scan
  174. ));
  175.  
  176. /*
  177.  * IndexScanRestorePosition --
  178.  *    General access method restore index scan position routine.
  179.  */
  180. extern
  181. void
  182. IndexScanRestorePosition ARGS((
  183.     IndexScanDesc    scan
  184. ));
  185.  
  186. /*
  187.  * IndexScanGetRetrieveIndexResult --
  188.  *    General access method low-level get index tuple routine.
  189.  *
  190.  * Note:
  191.  *    Assumes scan is valid.
  192.  *    This routine is likely to be useful only to the vacuum demon.
  193.  */
  194. extern
  195. RetrieveIndexResult
  196. IndexScanGetRetrieveIndexResult ARGS((
  197.     IndexScanDesc    scan,
  198.     ScanDirection    direction
  199. ));
  200.  
  201. /*
  202.  * IndexScanGetGeneralRetrieveIndexResult --
  203.  *    General access method general get index tuple routine.
  204.  *
  205.  * Note:
  206.  *    Assumes scan is valid.
  207.  */
  208. extern
  209. GeneralRetrieveIndexResult
  210. IndexScanGetGeneralRetrieveIndexResult ARGS((
  211.     IndexScanDesc    scan,
  212.     ScanDirection    direction
  213. ));
  214.  
  215. /* OBSOLETE
  216.  * IndexScanGetIndexTuple --
  217.  *    General access method get index tuple routine.
  218.  */
  219. extern
  220. GeneralRetrieveIndexResult
  221. IndexScanGetIndexTuple ARGS((
  222.     IndexScanDesc    scan,
  223.     Boolean        backward
  224. ));
  225.  
  226. /* ----------------
  227.  *    support macros for old index access method interface
  228.  * ----------------
  229.  */
  230.  
  231. /*
  232.  * RelationNameCreateIndexRelation --
  233.  *    General access method create index routine.
  234.  *
  235.  * paramter names abbreviated:
  236.  *    hRN -->     heapRelationName
  237.  *      iRN -->     indexRelationName
  238.  *      aMOI -->     accessMethodObjectId
  239.  *      n -->         numatts
  240.  *      a -->        attNums
  241.  *      cOI -->        classObjectId
  242.  *      pC -->        parameterCount
  243.  *      p -->        parameter
  244.  */
  245. #define RelationNameCreateIndexRelation(hRN, iRN, aMOI, n, a, cOI, pC, p) \
  246.     index_create(hRN, iRN, NULL, aMOI, n, a, cOI, pC, p, LispNil)
  247.  
  248. #define AMcreati(hRN, iRN, aMOI, n, a, cOI, pC, p) \
  249.     index_create(hRN, iRN, NULL, aMOI, n, a, cOI, pC, p, LispNil)
  250.  
  251. /*
  252.  * DestroyIndexRelationById --
  253.  *    General access method destroy index relation routine.
  254.  */
  255. #define DestroyIndexRelationById(indexId) \
  256.     index_destroy(indexId)
  257.  
  258. #define AMdestroy(indexId) \
  259.     index_destroy(indexId)
  260.  
  261. /*
  262.  * ObjectIdOpenIndexRelation --
  263.  *    General access method open index routine by object identifier routine.
  264.  */
  265. #define ObjectIdOpenIndexRelation(relationObjectId) \
  266.     index_open(relationObjectId)
  267.  
  268. #define AMopen(relationObjectId) \
  269.     index_open(relationObjectId)
  270.  
  271. /*
  272.  * AMopenr
  273.  */
  274. #define AMopenr(relationName) \
  275.     index_openr(relationName)
  276.  
  277. /*
  278.  * RelationCloseIndexRelation --
  279.  *    General access method close index relation routine.
  280.  */
  281. #define RelationCloseIndexRelation(relation) \
  282.     (void) index_close(relation)
  283.  
  284. #define AMclose(relation) \
  285.     (void) index_close(relation)
  286.  
  287. /*
  288.  * RelationInsertIndexTuple --
  289.  *    General access method index tuple insertion routine.
  290.  */
  291. #define RelationInsertIndexTuple(relation, indexTuple, scan, offsetOutP) \
  292.     ((GeneralInsertIndexResult)    index_insert(relation, indexTuple, offsetOutP))
  293.  
  294. #define AMinsert(relation, indexTuple, scan, offsetOutP) \
  295.     ((GeneralInsertIndexResult)    index_insert(relation, indexTuple, offsetOutP))
  296.  
  297. /*
  298.  * RelationDeleteIndexTuple --
  299.  *    General access method index tuple deletion routine.
  300.  */
  301. #define RelationDeleteIndexTuple(relation, indexItem) \
  302.     (void) index_delete(relation, indexItem)
  303.  
  304. #define AMdelete(relation, indexItem) \
  305.     (void) index_delete(relation, indexItem)
  306.  
  307. /*
  308.  * RelationSetIndexRuleLock --
  309.  *    General access method lock setting routine.
  310.  *
  311.  * XXX unimplemented
  312.  */
  313. #define RelationSetIndexRuleLock(relation, indexItem, lock) \
  314.     elog(DEBUG, "RelationSetIndexRuleLock; unimplemented")
  315.  
  316. #define AMsetlock(relation, indexItem, lock) \
  317.     elog(DEBUG, "AMsetlock; unimplemented")
  318.  
  319. /*
  320.  * RelationSetIndexItemPointer --
  321.  *    General access method base "tid" setting routine.
  322.  *
  323.  * XXX unimplemented
  324.  */
  325. #define RelationSetIndexItemPointer(relation, indexItem, heapItem) \
  326.     elog(DEBUG, "RelationSetIndexItemPointer: unimplemented")
  327.  
  328. #define AMsettid(relation, indexItem, heapItem) \
  329.     elog(DEBUG, "AMsettid: unimplemented")
  330.  
  331. /*
  332.  * AMbeginscan
  333.  */
  334. #define AMbeginscan(relation, scanFromEnd, numberOfKeys, key) \
  335.     ((IndexScanDesc) index_beginscan(relation, scanFromEnd, numberOfKeys, key))
  336. /*
  337.  * AMrescan
  338.  */
  339. #define AMrescan(scan, scanFromEnd, key) \
  340.     (void) index_rescan(scan, scanFromEnd, key)
  341. /*
  342.  * AMendscan
  343.  */
  344. #define AMendscan(scan) \
  345.     (void) index_endscan(scan)
  346. /*
  347.  * AMmarkpos
  348.  */
  349. #define AMmarkpos(scan) \
  350.     (void) index_markpos(scan)
  351. /*
  352.  * AMrestrpos
  353.  */
  354. #define AMrestrpos(scan) \
  355.     (void) index_restrpos(scan)
  356. /*
  357.  * AMgettuple
  358.  */
  359. #define AMgettuple(scan, direction) \
  360.     ((GeneralRetrieveIndexResult) \
  361.      IndexScanGetGeneralRetrieveIndexResult(scan, direction))
  362.  
  363. #endif    /* !defined(GenAMIncluded) */
  364.